import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-10-11
 * Time: 20:16
 */


//加上注解
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
        //这个方法一定要删除,否则会执行系统里的doGet方法
        //super.doGet(req, resp);

        //在服务器的控制台上打印hello,world
        System.out.println("hello,world");

        //相当于HTTP响应报文的body,在浏览器上显示给用户
        resp.getWriter().write("hello,world");

    }
}
